package com.konsung.ksdc.common.utils;

import android.app.Activity;

import java.util.ArrayList;
import java.util.List;

/**
 * activity集合处理类
 * Created by DJH on 2017/3/28 0028.
 */
public class ActivityCollector {
    public static List<Activity> activities = new ArrayList<Activity>();

    /**
     * 添加
     * @param activity 需要添加的activity
     */
    public static void addActivity(Activity activity) {
        activities.add(activity);
    }

    /**
     * 移除
     * @param activity 需要移除的activity
     */
    public static void removeActivity(Activity activity) {
        activities.remove(activity);
    }

    /**
     * 销毁集合中所有activity
     */
    public static void finishAll() {
        for (Activity activity : activities) {
            if (!activity.isFinishing()) {
                activity.finish();
            }
        }
        activities.clear();
    }
}
